<template>
    <div>
        <div v-if="!utils.getIsApp()" class="common-header-wrap">
            <mt-header class="common-header" title="经典线路">
                <mt-button icon="back" slot="left" @click="$router.go(-1)"></mt-button>
            </mt-header>
        </div>
        <index-banner v-if="banners && banners.length > 0" :items="banners"></index-banner>
        <div v-infinite-scroll="loadMore" infinite-scroll-disabled="loading" infinite-scroll-distance="10">
            <div v-if="linelist && linelist.length" class="travel-body">
                <div class="information-live" @click="goTeatraveldetail(item.id)" v-for="item in linelist">
                    <img class="information-video" :src="item.image">
                    <div class="information-live-title">
                        {{item.name}}
                    </div>
                    <div class="information-live-foot">
                        <div class="information-live-price">¥{{item.money}} 起</div>
                        <!--                <div class="information-live-btn">即刻出发</div>-->
                    </div>
                </div>
            </div>
            <empty-record v-else-if="linelist && !linelist.length"></empty-record>
        </div>
    </div>
</template>

<script>
    import {getTravelline} from '../../../api/travel'
    import IndexBanner from '../index/IndexBanner'
    import {mapState} from 'vuex'
    import {Toast,Indicator} from 'mint-ui'
    import EmptyRecord from '../../../components/EmptyRecord'

    export default {
        name: 'Teatravelline',
        data() {
            return {
                params: {'page': 0, 'per_page': 10},
                loading: false, // 是否加载更多
                isMore: true, // 是否有更多
                spot: '', // 景区id
                linelist: false // 线路列表
            }
        },
        components: {
            IndexBanner,
            EmptyRecord
        },
        computed: {
            ...mapState({
                banners: state => state.home.banners,
            })
        },
        mounted() {

        },
        methods: {
            goTeatraveldetail(id) {
                this.$router.push({name: 'HomeTeatraveldetail', query: {id,}})
            },
            // 加载数据
            loadMore() {
                this.loading = true
                this.params.page = ++this.params.page
                if (this.isMore) {
                    this.loading = false
                    this.getTravelline()
                }
            },
            //获取线路列表
            getTravelline() {
                getTravelline(this.params, this.$route.query.id).then(res => {
                    if (res.result.length < this.params.per_page) {
                        this.isMore = false
                    } else {
                        this.isMore = true
                    }
                    if(this.linelist){
                        this.linelist = this.linelist.concat(res.result)
                    }else {
                        this.linelist = res.result
                    }

                }).catch(function (error) {
                    Toast(error.message)
                })
            }
        }
    }
</script>

<style scoped lang='scss'>
    ::-webkit-scrollbar {
        display: none;
    }

    .label-title {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        height: 60px;
        margin: 0 20px;

        .label-title-font {
            font-size: .8rem;
            font-weight: bold;
        }

        .label-title-more {
            font-size: .6rem;
            color: #B5B5B5;
        }
    }

    .hot-travel {
        display: flex;
        flex-direction: row;
        overflow: scroll;
        padding: 0 20px;

        .hot-travel-list {
            display: flex;
            flex: none;
            flex-direction: column;
            align-items: center;
            margin-right: 20px;


            .hot-travel-img {
                width: 28vw;
                height: 21vw;
            }

            .hot-travel-name {
                margin-top: 5px;
                color: #B5B5B5;
                font-size: .6rem;
            }
        }
    }

    .travel-body {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 2vw;
        padding-bottom: 5vw;
        background: white;
    }

    .information-live {
        margin-left: 3vw;
        width: 44vw;
        margin-top: 3vw;
        background: white;
        box-shadow: 0 0 10px #ccc;
        border-radius: 8px;
    }

    .information-video {
        width: 44vw;
        height: 44vw;
        border-top-left-radius: 8px;
        border-top-right-radius: 8px;
    }

    .information-live-title {
        height: 1.8rem;
        padding: 5px 10px;
        padding-bottom: 0;
        font-size: .6rem;
        font-weight: bold;
        display: -webkit-box;
        overflow: hidden;
        -webkit-box-orient: vertical;
        text-overflow: ellipsis;
        -webkit-line-clamp: 2;
    }

    .information-live-foot {
        padding: 5px 10px;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .information-live-price {
        color: $primaryColor;
        font-size: .7rem;
        font-weight: bold;
    }

    .information-live-btn {
        background: $primaryColor;
        color: white;
        font-size: .7rem;
        border-radius: 5px;
        padding: 3px 15px;

    }
</style>
